package md.frolov.bible.model;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

public class Category implements IStructure, IViewLabelProvider{
	private Map<String,Language> languages = new HashMap<String,Language>();
	private String id;
	private String name;

	private Category(){}
	
	public Category(String id){
		this.id = id;
	}

	public Language getLanguageById(String languageId) {
		Language l = languages.get(languageId);
		if(l==null){
			l = new Language(languageId);
			languages.put(languageId,l);
		}
		return l;
	}

	@Override
	public Object[] getChildren() {
		return languages.values().toArray();
	}

	@Override
	public Object getParent() {
		return Archive.getInstance();
	}

	@Override
	public boolean hasChildren() {
		if(languages.values().size()>0) return true;
		return false;
	}
	
	public String getText(){
		return id;
	}

	@Override
	public String getId() {
		return id;
	}
}
